/* Root Variables */
:root {
  --primary-color: #1d7484;
  --secondary-color: #144f5a;
  --accent-color: #982c61;
  --text-color: #333;
  --background-color: #f9f9f9;
  --light-gray: #f1f1f1;
  --border-radius: 4px;
  --transition-speed: 0.3s ease;
  --base-font-size: 1.8rem; /* 18px */
}

/* Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 62.5%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-size: var(--base-font-size);
  line-height: 1.618;
  max-width: 42em;
  margin: auto;
  color: var(--text-color);
  background-color: var(--background-color);
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* Responsive Font Sizes for Body */
@media (max-width: 684px) {
  body {
    font-size: 1.6rem;
  }
}
@media (max-width: 382px) {
  body {
    font-size: 1.4rem;
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

h1 { font-size: 2.5em; color: var(--primary-color); }
h2 { font-size: 2em; color: var(--secondary-color); }
h3 { font-size: 1.75em; color: var(--accent-color); }
h4 { font-size: 1.5em; }
h5 { font-size: 1.25em; }
h6 { font-size: 1em; }

p {
  margin-bottom: 1.5rem;
}

small, sub, sup {
  font-size: 75%;
}

/* Horizontal Rule */
hr {
  border: 0;
  height: 1px;
  background: var(--primary-color);
  margin: 2rem 0;
}

/* Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-speed);
  word-break: break-word;
  overflow-wrap: break-word;
  /* Default links are inline for proper text wrapping */
  display: inline;
  max-width: 100%;
}

a:visited {
  color: var(--secondary-color);
}

a:hover,
a:focus {
  color: var(--accent-color);
  text-decoration: underline;
}

/* Lists */
ul, ol {
  padding-left: 1.5em;
  margin-bottom: 1.5rem;
}

li {
  margin-bottom: 0.5em;
}

/* Blockquotes */
blockquote {
  padding: 1em;
  border-left: 5px solid var(--primary-color);
  margin-bottom: 1.5rem;
  background-color: var(--light-gray);
  color: #555;
  font-style: italic;
}

/* Images and Videos */
img, video {
  height: auto;
  max-width: 100%;
  margin-bottom: 1.5rem;
  border-radius: var(--border-radius);
}

/* Code Blocks */
pre, code, kbd, samp {
  background-color: var(--light-gray);
  border-radius: var(--border-radius);
  font-size: 0.9em;
  padding: 0.5em;
  white-space: pre-wrap;
}

pre {
  padding: 1em;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

pre > code {
  background-color: transparent;
  padding: 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

th, td {
  padding: 0.75em;
  border-bottom: 1px solid var(--light-gray);
  text-align: left;
}

th {
  background-color: var(--primary-color);
  color: var(--background-color);
}

/* Forms */
input, textarea, select {
  border: 1px solid #ccc;
  padding: 0.75em;
  margin-bottom: 1rem;
  width: 100%;
  border-radius: var(--border-radius);
  transition: border-color var(--transition-speed);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary-color);
  outline: none;
}

textarea {
  resize: vertical;
}

/* Buttons */
.button, button, input[type="submit"], input[type="reset"], input[type="button"] {
  display: inline-block;
  padding: 0.75em 1.5em;
  background-color: var(--primary-color);
  color: var(--background-color);
  border-radius: var(--border-radius);
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-speed);
}

.button:hover, button:hover, input[type="submit"]:hover {
  background-color: var(--secondary-color);
}

.button:focus-visible {
  outline: 2px solid var(--accent-color);
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Labels and Legends */
label, legend, fieldset {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* Grid System */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.col {
  flex: 1;
  padding: 10px;
}

/* Responsive Column Stack */
@media (max-width: 768px) {
  .col {
    flex-basis: 100%;
  }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.hidden { display: none; }
.show { display: block; }

/* Accessibility Improvements */
:focus {
  outline: 2px dashed var(--accent-color);
  outline-offset: 2px;
}
